// 网页加载完成后在执行JS的代码
window.addEventListener("load", function () {
	var mySwiper = new Swiper(".swiper", {
		autoplay: true, //可选选项，自动滑动
		pagination: {
			el: ".swiper-pagination",
			clickable: true,
		},
	});

	//如果.你初始化时没有定义Swiper实例，后面也可以通过Swiper的HTML元素来获取该实例
	new Swiper(".swiper");
	var mySwiper = document.querySelector(".swiper").swiper;
	mySwiper.slideNext();
	// API
	let apiList = document.querySelectorAll("#apiList li");

	apiList.forEach(function (v, i) {
		let a = "0";
		if (i < 9) {
			a = `0${i + 1}`;
		} else {
			a = i + 1;
		}
		v.addEventListener("mouseover", function () {
			v.firstElementChild.src = `../imgs/api${a}-c.svg`;
		});
		v.addEventListener("mouseout", function () {
			v.firstElementChild.src = `../imgs/api${a}.svg`;
		});
	});
	// 慧集
	// 实现轮播效果
	let timer = "";
	$("#unicornBack .container")[0].style.opacity = 1;
	function time() {
		let i = 1;
		timer = window.setInterval(function () {
			$("#unicornBack .container").forEach(function (v) {
				v.style.opacity = 0;
			});
			$("#unicornBack .container")[i].style.opacity = 1;
			i++;
			if (i > 2) {
				i = 0;
			}
		}, 3000);
	}
	// 轮播图调用
	time();
	// 点击之后暂停,再次点击继续
	let flag = true;
	$("#unicornBack .container").forEach(function (v) {
		v.addEventListener("click", function () {
			if (flag) {
				clearInterval(timer);
				timer = null;
			} else {
				time();
			}
			flag = !flag;
		});
	});
	// 回到顶部
	this.window.addEventListener("scroll", function () {
		if (this.scrollY >= 1250) {
			$("#getTop").style.opacity = 1;
		} else {
			$("#getTop").style.opacity = 0;
		}
		$("#getTop").addEventListener("click", function () {
			scrollTo({left:0, top:0,behavior:"smooth"});
		});
	});





});
